-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ResponseOps][Rules] Remove unintended internal Find routes API with public access #193757
[ResponseOps][Rules] Remove unintended internal Find routes API with public access #193757
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a unit test (x-pack/plugins/alerting/server/routes/rule/apis/find/find_rules_route.test.ts
) to be sure we register the correct routes with the correct access
?
x-pack/plugins/alerting/server/routes/rule/apis/find/find_rules_route.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obs-ux-management changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approved the PR but I never liked how we structured the code in find_rules_route.ts
and I think in part that is the reason we had the bug.
It is not the scope of this issue so I'll leave it up to you but I was thinking the following:
What is the point of having a buildFindRulesRoute
function?
- It is not exported anywhere else.
- Its logic is completely different if the route is internal or external.
- the
if else
being based on the URL doesn't feel right, what if I wanted to "build a find rules route" that is internal but with a different URL? - Why have the
options
as params? For the external API they are hardcoded, we can put them inside theif
. For the internal route we don't need theoptions
.
I think this aux buildFindRulesRoute
function does more harm than good. We could move the code inside findRulesRoute
and findInternalRulesRoute
and have them be completely separate. (Maybe even separate files.)
+1 to what @adcoelho said. Same for the integration tests. |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for splitting the routes into different files! What do you think of splitting also the integration files into find.ts
and find_internal.ts
?
x-pack/test/alerting_api_integration/security_and_spaces/group1/tests/alerting/find.ts
Show resolved
Hide resolved
@@ -332,7 +332,6 @@ export default function createFindTests({ getService }: FtrProviderContext) { | |||
afterEach(() => objectRemover.removeAll()); | |||
|
|||
findTestUtils('public', supertest, objectRemover); | |||
findTestUtils('internal', supertest, objectRemover); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep this?
….com/Zacqary/kibana into 192957-remove-internal-public-access
…nal-public-access
💛 Build succeeded, but was flaky
Failed CI StepsTest FailuresMetrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience with the review in this PR!
@@ -22,6 +22,7 @@ export default function alertingTests({ loadTestFile, getService }: FtrProviderC | |||
|
|||
loadTestFile(require.resolve('./backfill')); | |||
loadTestFile(require.resolve('./find')); | |||
loadTestFile(require.resolve('./find_internal')); | |||
loadTestFile(require.resolve('./find_with_post')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need the find_with_post
file anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule Management changes LGTM. I pulled the PR and tested rule snoozing locally to confirm that our dependency on the internal find endpoint hasn't been impacted - everything seems to work fine.
Thanks @Zacqary 👍 ✅
Starting backport for target branches: 8.16, 8.x https://github.com/elastic/kibana/actions/runs/11473099213 |
…public access (elastic#193757) ## Summary Fixes elastic#192957 Removes the `internal/_find` route from public access by moving the hard-coded `options` into the route builder functions. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 196caba)
…public access (elastic#193757) ## Summary Fixes elastic#192957 Removes the `internal/_find` route from public access by moving the hard-coded `options` into the route builder functions. --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 196caba)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…I with public access (#193757) (#197358) # Backport This will backport the following commits from `main` to `8.16`: - [[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)](#193757) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Zacqary Adam Xeper","email":"Zacqary@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-23T04:33:31Z","message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v9.0.0","Feature:Alerting/RulesFramework","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"title":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access","number":193757,"url":"https://github.com/elastic/kibana/pull/193757","mergeCommit":{"message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193757","number":193757,"mergeCommit":{"message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Zacqary Adam Xeper <Zacqary@users.noreply.github.com>
… with public access (#193757) (#197359) # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)](#193757) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Zacqary Adam Xeper","email":"Zacqary@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-23T04:33:31Z","message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","v9.0.0","Feature:Alerting/RulesFramework","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"title":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access","number":193757,"url":"https://github.com/elastic/kibana/pull/193757","mergeCommit":{"message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193757","number":193757,"mergeCommit":{"message":"[ResponseOps][Rules] Remove unintended internal Find routes API with public access (#193757)\n\n## Summary\r\n\r\nFixes #192957 \r\n\r\nRemoves the `internal/_find` route from public access by moving the\r\nhard-coded `options` into the route builder functions.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"196cabad9bbd0511219fc7833a62cb8a0bb61514"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Zacqary Adam Xeper <Zacqary@users.noreply.github.com>
Summary
Fixes #192957
Removes the
internal/_find
route from public access by moving the hard-codedoptions
into the route builder functions.